//Save As
private: System::Void menuItem6_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 if(SaveTGN->ShowDialog() == DialogResult::OK)
			 {
				 //file->Clear();
				 file->DeleteAllAnis();

				 TGNFrame *newFrame;

				 //populate the file
				 for(int i = 0; i < AniList->Items->Count; i++)
				 {
					 //UGLIEST CODE IVE EVER WRITTEN FOLLOWS

					 //load the animation (zero the frame count first, so when I AddFrame, it stays correct)
					 ((AnimObject*)AniList->Items->Item[i])->GetAni()->numFrames = 0;
					 file->AddAni(((AnimObject*)AniList->Items->Item[i])->GetAni());

					 //for every frame the animation contains
					 for(int j = 0; j < ((AnimObject*)AniList->Items->Item[i])->frames->Count; j++)
					 {
						 newFrame = ((FrameObject*)((AnimObject*)AniList->Items->Item[i])->frames->Item[j])->f;
						 file->AddFrame(i, newFrame);
					 }
					 
				 }

				 file->SetID(Decimal::ToInt32(mainID->Value));
				 file->Save(StringToArray(SaveTGN->FileName));

				 currentFile = SaveTGN->FileName;
				 needsSave(false);
			 }
		 }

//Open
private: System::Void menuItem7_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			if(needSave)
				if(MessageBox::Show("Any unsaved work will be deleted, continue?", "Warning!", MessageBoxButtons::OKCancel) == DialogResult::Cancel)
					return;
				
			if(LoadTGN->ShowDialog() == DialogResult::OK)
			{
				ZoomOut_Click(NULL, NULL);

				file->Clear();
				file->Load(StringToArray(LoadTGN->FileName));

				mainID->Value = file->GetID();

				Image *pix = NULL;

				if(System::IO::File::Exists(ArrayToString(file->GetImageName())))
				{
					pix = Image::FromFile(ArrayToString(file->GetImageName()));
					pathName->Text = file->GetImageName();

					ImageBox->Width = pix->Width;
					ImageBox->Height = pix->Height;
					ImageBox->Image = pix;

					origW = pix->Width;
					origH = pix->Height;
				}
				else
				{
					MessageBox::Show("Image was invalid. Please add the image to the file again.");
				}

				AniList->Items->Clear();

				FrameList->DataSource = NULL;
				FrameList->Items->Clear();

				AnimObject *newListItem = NULL;
				FrameObject *newFrameObject = NULL;
				TGNAni *newAni = NULL;

				for(int i = 0; i < file->NumAnis(); i++)
				{
					newListItem = new AnimObject;
					newAni = new TGNAni;

					*newAni = *file->GetAni(i);

					newListItem->SetAni(newAni);
					AniList->Items->Add((Object*)newListItem);

					for(int j = 0; j < newAni->numFrames; j++)
					{
						newFrameObject = new FrameObject;
						newFrameObject->f = new TGNFrame;

						*newFrameObject->f = *file->GetFrame(i, j);
						newListItem->AddFrame(newFrameObject);
					}
				}

				/*for(int i = 0; i < file->GetAniCount(); i++)
					AniList->Items->Add(S"Animation");*/

				currentFile = LoadTGN->FileName;
				this->Text = Text->Concat("Trygon Editor - ", currentFile);
			 }
		 }

//Save
private: System::Void menuItem5_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 //make this work
			 if(currentFile->Equals("New.tgn"))
			 {
				 menuItem6_Click(NULL, NULL);
			 }
			 else
			 {
				 //file->Clear();
				 file->DeleteAllAnis();

				 TGNFrame *newFrame;

				 //populate the file
				 for(int i = 0; i < AniList->Items->Count; i++)
				 {
					 //UGLIEST CODE IVE EVER WRITTEN FOLLOWS

					 //load the animation (zero the frame count first, so when I AddFrame, it stays correct)
					 ((AnimObject*)AniList->Items->Item[i])->GetAni()->numFrames = 0;
					 file->AddAni(((AnimObject*)AniList->Items->Item[i])->GetAni());

					 //for every frame the animation contains
					 for(int j = 0; j < ((AnimObject*)AniList->Items->Item[i])->frames->Count; j++)
					 {
						 newFrame = ((FrameObject*)((AnimObject*)AniList->Items->Item[i])->frames->Item[j])->f;
						 file->AddFrame(i, newFrame);
					 }
					 
				 }

				 file->SetID(Decimal::ToInt32(mainID->Value));
				 file->Save(StringToArray(currentFile));

				 needsSave(false);

				 /*file->SetID(Decimal::ToInt32(mainID->Value));
				 file->Save(StringToArray(currentFile));
				 needsSave(false);*/
			 }

		 }

//New
private: System::Void menuItem4_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			if(needSave)
				if(MessageBox::Show("Any unsaved work will be deleted, continue?", "Warning!", MessageBoxButtons::OKCancel) == DialogResult::Cancel)
					return;
				
			file->Clear();
			ImageBox->Image = NULL;
			AniList->Items->Clear();
			FrameList->DataSource = NULL;
			pathName->Clear();

			currentFile = "New.tgn";
			needsSave(false);
		 }

private: System::Void menuItem9_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 MessageBox::Show("Created by Casey Clyde and Lyle Underwood, August 2006-March 2007 \n Any questions or bugs to CaseySClyde@gmail.com");
		 }

//Alpha
private: System::Void menuItem14_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 if(alphaDialog->ShowDialog() == DialogResult::OK)
				 file->SetAlpha(alphaDialog->Color.ToArgb());
		 }

private: System::Void toolBar1_ButtonClick(System::Object *  sender, System::Windows::Forms::ToolBarButtonClickEventArgs *  e)
		 {
			 switch(toolBar1->Buttons->IndexOf( e->Button ) )
			 {
			 case 0:
				 menuItem4_Click(NULL, NULL);
				 break;
			 case 1:
				 menuItem7_Click(NULL, NULL);
				 break;
			 case 2:
				 menuItem5_Click(NULL, NULL);
				 break;
			 case 4:
				 menuItem14_Click(NULL, NULL);
				 break;
			 case 6:
				 menuItem9_Click(NULL, NULL);
				 break;
			 }
		 }

private: System::Void menuItem8_Click(System::Object *  sender, System::EventArgs *  e)
		 {
			 if(needSave)
			 {
				if(MessageBox::Show("Are you sure you want to quit?", "Warning!", MessageBoxButtons::OKCancel) == DialogResult::OK)
					this->Close();
			 }
			 else if(!needSave)
			 {
				 this->Close();
			 }
				
		 }